package org.yx.service.sres.view_spot_check;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SresSptChk;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查询点检项目
 * 
 * @author zxw
 * @since 2019/09/04
 **/
public class SresViewSpotCheckService extends BaseService {
	public SresViewSpotCheckOut viewSpotCheck(SresViewSpotCheckIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		query.addFilter("status", "<>", 'D');
		if (StrUtil.isNotBlank(in.getCheckCode())) {
			query.addFilter("checkCode", in.getCheckCode());
		}
		if (StrUtil.isNotBlank(in.getCheckName())) {
			query.addFilter("checkName", "like", "%" + in.getCheckName() + "%");
		}

		Page<SresSptChk> chkPage = selectPage(SresSptChk.class, query);

		SresViewSpotCheckOut out = new SresViewSpotCheckOut();
		out.setCheckList(chkPage.getList());
		out.setTotal(chkPage.getTotalSize());

		return out;
	}
}